<div class="content-section introduction">
    <div class="feature-intro">
        <h1>Paginator</h1>
        <p>Paginator is a generic component to display content in paged format.</p>
    </div>
    <app-demoActions github="paginator" stackblitz="paginator-demo"></app-demoActions>
</div>

<div class="content-section implementation">
    <div class="card">
        <h5>Basic</h5>
        <p-paginator [rows]="10" [totalRecords]="totalRecords" [rowsPerPageOptions]="[10,20,30]"></p-paginator>

        <h5>Custom</h5>
        <div class="grid align-items-center">
            <div class="col-1">
                <p-button icon="pi pi-refresh" (onClick)="refresh()"></p-button>
            </div>
            <div class="col-10">
                <p-paginator [first]="first" [rows]="1" [totalRecords]="totalRecords2" (onPageChange)="onPageChange($event)"
                [showJumpToPageDropdown]="true" [showPageLinks]="false"></p-paginator>
            </div>
            <div class="col-1 grid justify-content-end">
                <p-button icon="pi pi-search"></p-button>
            </div>
        </div>
        <div class="image-gallery">
            <img src="assets/showcase/images/demo/nature/nature{{first + 1}}.jpg" />
        </div>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;PaginatorModule&#125; from 'primeng/paginator';
</app-code>

            <h5>Getting Started</h5>
            <p>Paginator is defined using p-paginator element.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-paginator&gt;&lt;/p-paginator&gt;
</app-code>
            <h5>Rows and TotalRecords</h5>
            <p><i>rows</i> and <i>totalRecords</i> define how many pages the paginator should display. Paginator below will have 10 pages.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-paginator [rows]="10" [totalRecords]="100"&gt;&lt;/p-paginator&gt;
</app-code>

            <h5>PageLinks</h5>
            <p>PageLinks provide shortcuts to jump to a specific page, use <i>pageLinkSize</i> property to define the number of links to display. Default is 5.</p>

<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-paginator [rows]="10" [totalRecords]="100" pageLinkSize="3"&gt;&lt;/p-paginator&gt;
</app-code>

            <h5>Rows Per Page</h5>
            <p>Number of items per page can be changed by the user using a dropdown if you define <i>rowsPerPageOptions</i> as an array of possible values.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-paginator [rows]="10" [totalRecords]="120" [rowsPerPageOptions]="[10,20,30]"&gt;&lt;/p-paginator&gt;
</app-code>

            <h5>CurrentPageReport</h5>
            <p>Current page report item in the template displays information about the pagination state. Default value is (&#123;currentPage&#125; of &#123;totalPages&#125;)
                whereas available placeholders are the following;
            </p>
            <ul>
                <li>&#123;currentPage&#125;</li>
                <li>&#123;totalPages&#125;</li>
                <li>&#123;rows&#125;</li>
                <li>&#123;first&#125;</li>
                <li>&#123;last&#125;</li>
                <li>&#123;totalRecords&#125;</li>
            </ul>

            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>totalRecords</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Number of total records.</td>
                        </tr>
                        <tr>
                            <td>rows</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Data count to display per page.</td>
                        </tr>
                        <tr>
                            <td>first</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Zero-relative number of the first row to be displayed.</td>
                        </tr>
                        <tr>
                            <td>pageLinkSize</td>
                            <td>number</td>
                            <td>5</td>
                            <td>Number of page links to display.</td>
                        </tr>
                        <tr>
                            <td>rowsPerPageOptions</td>
                            <td>array</td>
                            <td>null</td>
                            <td>Array of integer/object values to display inside rows per page dropdown.
                                A object that have 'showAll' key can be added to it to show all data. Exp; [10,20,30,&#123;showAll:'All'&#125;] </td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>alwaysShow</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Whether to show it even there is only one page.</td>
                        </tr>
                        <tr>
                            <td>showFirstLastIcon</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>When enabled, icons are displayed on paginator to go first and last page.</td>
                        </tr>
                        <tr>
                            <td>templateLeft</td>
                            <td>TemplateRef</td>
                            <td>null</td>
                            <td>Template instance to inject into the left side of the paginator.</td>
                        </tr>
                        <tr>
                            <td>templateRight</td>
                            <td>TemplateRef</td>
                            <td>null</td>
                            <td>Template instance to inject into the right side of the paginator.</td>
                        </tr>
                        <tr>
                            <td>dropdownItemTemplate</td>
                            <td>TemplateRef</td>
                            <td>null</td>
                            <td>Template instance to inject into the dropdown item inside in the paginator.</td>
                        </tr>
                        <tr>
                            <td>dropdownAppendTo</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Target element to attach the dropdown overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).</td>
                        </tr>
                        <tr>
                            <td>dropdownScrollHeight</td>
                            <td>string</td>
                            <td>200px</td>
                            <td>Dropdown height of the viewport in pixels, a scrollbar is defined if height of list exceeds this value.</td>
                        </tr>
                        <tr>
                            <td>currentPageReportTemplate</td>
                            <td>string</td>
                            <td>(&#123;currentPage&#125; of &#123;totalPages&#125;)</td>
                            <td>Template of the current page report element. Available placeholders are
                                &#123;currentPage&#125;,&#123;totalPages&#125;,&#123;rows&#125;,&#123;first&#125;,&#123;last&#125; and &#123;totalRecords&#125;
                            </td>
                        </tr>
                        <tr>
                            <td>showCurrentPageReport</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Whether to display current page report.</td>
                        </tr>
                        <tr>
                            <td>showJumpToPageDropdown</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Whether to display a dropdown to navigate to any page.</td>
                        </tr>
                        <tr>
                            <td>showJumpToPageInput</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Whether to display a input to navigate to any page.</td>
                        </tr>
                        <tr>
                            <td>showPageLinks</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Whether to show page links.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Events</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Parameters</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onPageChange</td>
                            <td>event.first: Index of first record <br>
                                event.rows: Number of rows to display in new page <br>
                                event.page: Index of the new page <br>
                                event.pageCount: Total number of pages <br></td>
                            <td>Callback to invoke when page changes, the event object contains information about the new state.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-paginator [rows]="10" totalRecords="100" (onPageChange)="paginate($event)"&gt;&lt;/p-paginator&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class MyComponent &#123;

    paginate(event) &#123;
        //event.first = Index of the first record
        //event.rows = Number of rows to display in new page
        //event.page = Index of the new page
        //event.pageCount = Total number of pages
    &#125;

&#125;
</app-code>

            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Element</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-paginator</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>p-paginator-first</td>
                            <td>First page element.</td>
                        </tr>
                        <tr>
                            <td>p-paginator-prev</td>
                            <td>Previous page element.</td>
                        </tr>
                        <tr>
                            <td>p-paginator-pages</td>
                            <td>Container of page links.</td>
                        </tr>
                        <tr>
                            <td>p-paginator-page</td>
                            <td>A page link.</td>
                        </tr>
                        <tr>
                            <td>p-paginator-next</td>
                            <td>Next page element.</td>
                        </tr>
                        <tr>
                            <td>p-paginator-last</td>
                            <td>Last page element.</td>
                        </tr>
                        <tr>
                            <td>p-paginator-rpp-options</td>
                            <td>Rows per page dropdown.</td>
                        </tr>
                        <tr>
                            <td>p-paginator-page-options</td>
                            <td>Jump to per page dropdown.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/paginator" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-paginator-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-paginator [rows]="10" [totalRecords]="120" [rowsPerPageOptions]="[10,20,30]"&gt;&lt;/p-paginator&gt;
&lt;h5&gt;Basic&lt;/h5&gt;
    &lt;p-paginator [rows]="10" [totalRecords]="totalRecords" [rowsPerPageOptions]="[10,20,30]"&gt;&lt;/p-paginator&gt;

    &lt;h5&gt;Custom&lt;/h5&gt;
    &lt;div class="grid align-items-center"&gt;
        &lt;div class="col-1"&gt;
            &lt;p-button icon="pi pi-refresh" (onClick)="refresh()"&gt;&lt;/p-button&gt;
        &lt;/div&gt;
        &lt;div class="col-10"&gt;
            &lt;p-paginator [first]="first" [rows]="1" [totalRecords]="totalRecords2" (onPageChange)="onPageChange($event)"
            [showJumpToPageDropdown]="true" [showPageLinks]="false"&gt;&lt;/p-paginator&gt;
        &lt;/div&gt;
        &lt;div class="col-1 grid justify-content-end"&gt;
            &lt;p-button icon="pi pi-search"&gt;&lt;/p-button&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="image-gallery"&gt;
        &lt;img src="assets/showcase/images/demo/nature/nature&#123;&#123;first + 1&#125;&#125;.jpg" /&gt;
    &lt;/div&gt;
&lt;/div&gt;
</app-code>
<app-code lang="css">
.image-gallery &#123;
    text-align: center;
    padding: 1rem;
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-paginator-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>
